import React, { Component } from 'react';
import axios  from "axios";
import  jsonp   from "jsonp";

class Test extends Component {
    constructor(props) {
        super(props);
      this.state={ };
    }
      sleep =(milliSeconds)=>{
        var startTime = new Date().getTime(); // get the current time    
        while (new Date().getTime() < startTime + milliSeconds);
    }
    
    componentWillMount() {
        // axios.get('http://baike.baidu.com/api/openapi/BaikeLemmaCardApi?scope=103&format=json&appid=379020&bk_key=%E9%93%B6%E9%AD%82&bk_length=600&callback=123').then(response=>{
        //     console.log(response)
        // })
        jsonp('http://baike.baidu.com/api/openapi/BaikeLemmaCardApi?scope=103&format=json&appid=379020&bk_key=%E9%93%B6%E9%AD%82&bk_length=600', null, (err, data) =>{
            if (err) {
              console.error(err.message);
            } else {
                this.sleep(1000*5)
                this.setState(data)
             
             
            }
          });
    }
    componentDidMount =()=>{
        console.log(this.state)
        setInterval(()=>{
            console.log(this.state)
        },1000*3)
    }
    

  

    render() {
        return (
            <div>
                {this.state.desc}
            </div>
        );
    }
}

 

export default Test;